package br.com.lh.urabuilder.command
{
	import br.com.lh.urabuilder.business.ViewManager;
	import br.com.lh.urabuilder.command.base.UraBaseCommand;
	import br.com.lh.urabuilder.event.AddActionEvent;
	import br.com.lh.urabuilder.event.RemoveActionEvent;
	import br.com.lh.urabuilder.view.ActionComponent;
	
	import com.adobe.cairngorm.control.CairngormEvent;
	
	public class RemoveActionCommand extends UraBaseCommand
	{
		private var currentElement:ActionComponent; 
		
		public function RemoveActionCommand(){
			
		}
		
		public override function redo( event: CairngormEvent =null): void{
			this.currentElement = RemoveActionEvent(event).element;
			var viewManager:ViewManager = uraModelLocator.viewManager;
			viewManager.removeComponent(currentElement);
			uraModelLocator.xmlManager.removeElement(currentElement.uraAction);
		}
		
		public override function undo():void{
			cairngormEventDispatcher.dispatchEvent(new AddActionEvent(currentElement));
		}

	}
}